﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Globalization;

namespace hozoroghiab
{
    public partial class absentofday : Form
    {
        public sql sqlquery;
        public absentofday(sql s)
        {
            InitializeComponent();
            sqlquery = s;
        }

        private void absentofday_Load(object sender, EventArgs e)
        {
            PersianCalendar per = new PersianCalendar();
            string year = per.GetYear(DateTime.Now).ToString();
            string month = per.GetMonth(DateTime.Now).ToString();
            toolStripTextBox1.Text = year;
            monthtoolStripComboBox.Text = month;
            dataGridView1.ReadOnly = true;
            dataGridView1.AllowUserToAddRows = false;
            setdatagrideview(year,month);

        }



        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            setdatagrideview(toolStripTextBox1.Text, monthtoolStripComboBox.Text);
        }
        void setdatagrideview(string year,string month)
        {
            sqlquery.open();
            SqlDataAdapter da = sqlquery.sqlcommand("SELECT DISTINCT profile.employeid,name,family,entry.year,entry.month,entry.day FROM profile,entry WHERE entry.year=" + year + " and entry.month=" + month + " and entry.day between 1 and 31 and not exists (select employeid from entry Where profile.employeid=entry.employeid) order by entry.day");
            DataTable table = new DataTable();
            table.Locale = System.Globalization.CultureInfo.InvariantCulture;
            da.Fill(table);
            dataGridView1.DataSource = table;
            sqlquery.close();
        }

       
    }
}
